package com.castudio.Controller;

import com.castudio.Entity.Superuser;
import com.castudio.Filter.Result;
import com.castudio.Service.SuperuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小陈同学
 * @since 2022-12-14
 */
@RestController
@RequestMapping("/superuser")
public class SuperuserController {

    @Autowired
    private SuperuserService superuserService;

    @PostMapping("/login")
    public Result login(@RequestBody Superuser superuser){

        List list = superuserService.lambdaQuery()
                .eq(Superuser ::getUsername,superuser.getUsername())
                .eq(Superuser ::getPassword,superuser.getPassword())
                .list();

        return list.size()>0?Result.success(list.get(0)) : Result.failure();

    }

}
